package cic;

import java.util.Date;

public class Employee implements IEmployee {

	private String name;
	private String id;
	private Department dep;
	private Level level;
	
	public Employee(String name, String id, Department dep, Level lv) {
		this.name = name;
		this.id = id;
		this.dep = dep;
		this.level = lv;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getID() {
		return id;
	}

	public void setID(String id) {
		this.id = id;
	}

	public Department getDepartment() {
		return dep;
	}

	public void setDepartment(Department dep) {
		this.dep = dep;

	}
	
	public Level getLevel() {
		return level;
	}

	public void setLevel(Level lv) {
		this.level = lv;
		
	}
	
	public Letter writeLetter(String content) {
		
		if (dep == Department.CarDamages) {
		
			Letter letter = new Letter(name, id, new Date(), content);
			return letter;
			
		} else {
			return null;
		}
	}
	
	public boolean phoneGarage() {
		
		if (dep == Department.CarDamages) {
			return true;
		} else {
			return false;
		}
	}
	
	public boolean pay(Claim clm) {
		
		if ((dep == Department.Finance) || (clm.getDecision().equalsIgnoreCase("OK"))) {
			return true;
		} else {
			return false;
		}
		
	}

	public void evaluate(InsuranceManager manager, Claim clm) {
		
		String insurance_num = clm.getInsurance_num();
		Insurance insurance = manager.getInsurance(insurance_num);
		
		if (insurance.car_price > 99999) {
			clm.setCategory(Category.complex_claim);
		} else if (insurance.accidents == 0) {
			clm.setCategory(Category.complex_claim);
		} else {
			clm.setCategory(Category.simple_claim);
		}
		
	}
	
	public void makeDecision(Claim clm, String decision) {
		clm.setDecision(decision);
	}
	
	public void regiserClaim(Claim clm) {
		if ((dep == Department.CarDamages) || (level == Level.C)) {
			clm.setIsregistered(true);
		}
	}
	
    public boolean checkInsurance(InsuranceManager manager, Claim clm) {
    	
		String insurance_num = clm.getInsurance_num();
		Insurance insurance = manager.getInsurance(insurance_num);
		
		if (insurance != null) {
			return true;
		} else {
			return false;
		}
    }
    
    public void checkHistory(InsuranceManager manager, Claim clm) {
    	
		String insurance_num = clm.getInsurance_num();
		Insurance insurance = manager.getInsurance(insurance_num);
		
		insurance.accidents++;
    }



}
